const fs = require('fs')

/* fs.readFile('./files/chengji.txt','utf8',(err,data)=> {
    if(err) return console.log(err)
    if(data) console.log(data)
    let str = data
    while(str.indexOf(' ') != -1) {
        str = str.replace(' ','\n')
    }

    while(str.indexOf('=') != -1) {
        str = str.replace('=',': ')
    }
    console.log(str)
}) */


let fn = (myStr,a,b)=> {
    while(myStr.indexOf(a) != -1) {
        myStr = myStr.replace(a,b)
    }
    return myStr
}

fs.readFile('./files/chengji.txt','utf8',(err,data)=> {
    if(err) return console.log(err)
    if(data) console.log(data)
    let str = data
   str = fn(str,' ', '\n')
   str =  fn(str, '=',': ')
   fs.writeFile('files/chengji-ok.txt',str,'utf8',err=>console.log(err))
    console.log(str)
})

